package fr.esiag.projet17.persistence.dao.oracle;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.Properties;

import fr.esiag.projet17.persistence.dao.IDAO;

public abstract class DAO<T> implements IDAO<T> {

	protected static Connection connection;
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public DAO() {
		if (connection == null) {
			try {
				Properties props = DAOFactory.getProps();
				String driverName = props.getProperty("sql.driver");
				Class.forName(driverName);
				String url = props.getProperty("sql.url");
				String login = props.getProperty("sql.login");
				String password = props.getProperty("sql.password");
				connection = DriverManager.getConnection(url, login, password);
			} catch (SQLException e) {
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} 
		}
	}

}
